<template>
  <view class="mdlBox">

    <view class="popularizeBox">
      <view :class="active=='direct'?'active':''" @click="cutover('direct')">直接推广会员</view>
      <view :class="active=='summary'?'active':''" @click="cutover('summary')">间接推广会员</view>
    </view>
    <view >
      <view class="mdlBoxContent">
        <text class="time">昵称</text>
        <text class="form">手机号</text>
        <text class="number">时间</text>
      </view>
      <view class="mdlBoxContent select" v-for="(item,index) in dataList" :key="index">
        <text class="time">{{item.realname}}</text>
        <text class="form">{{item.mobile}}</text>
        <text class="number">{{item.create_at}}</text>
      </view>
      <rf-empty info="暂无推广会员" :isRecommendShow="false" v-if="dataList.length === 0"></rf-empty>
    </view>
  </view>
</template>

<script>
import { myIndirectTeam , myDirectTeam} from "@/api/product";
export default {

  data() {
    return {
      money:'888.78',
      active:'direct',
      dataList:[],
      directMembers:[],
      indirectMembers:[],
      page:1,
      flag1:true,
      flag2:true,
      goodsList:[],
    };
  },
  onLoad(){
    this.myDirectTeam(1);
  },
  onReachBottom() {
    if (this.flag1 &&　this.active=="direct"){
      this.page += 1;
      this.myDirectTeam(2)
    }else if (this.flag2 &&　this.active!="direct"){
      this.page += 1;
      this.myIndirectTeam(2)
    }

  },
  methods: {
    cutover(type){
      this.active = type;
      this.page = 1;
      if (type == 'direct'){
        this.myDirectTeam(1);
      }else {
        this.myIndirectTeam(1);
      }
    },
    myDirectTeam(type){
      this.$get(`${myDirectTeam}`, {page:this.page,pagesize:20}).then(async r => {
        if (r.data.length !=20){
          this.flag1 = false;
        }
        if (type==1){
          this.dataList = r.data;
        }else {
          this.dataList = [...this.dataList,...r.data];
        }

      }).catch(err => {

        console.log(err);
      })
    },
    myIndirectTeam(type){
      this.$get(`${myIndirectTeam}`, {page:this.page,pagesize:20}).then(async r => {
        if (r.data.length !=20){
          this.flag2 = false;
        }
        if (type==1){
          this.dataList = r.data;
        }else {
          this.dataList = [...this.dataList,...r.data];
        }
      }).catch(err => {

        console.log(err);
      })
    }
  },
}
</script>

<style lang="less" >

page{
  background: #fff;
}
.mdlBox{
  width: 92%;
  margin: 0 auto;
  padding-top: 40rpx;
}
.mdlBoxTitle{
  font-size: 32upx;
  font-family: PingFang SC;
  font-weight: bold;
  color: #343434;
  line-height: 60px;
}
.popularizeBox{
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16upx;
  border: 1px solid #f2f2f2;
  height: 68upx;
  color:#343434;
  overflow: hidden;
  margin: 0 auto 40upx;
  z-index: 2;
  position: relative;
  view{
    width: 50%;
    text-align: center;
    font-weight: 700;
    font-size: 30upx;
    height: 68upx;
    line-height: 68upx;
  }
  .active{
    background: #FC9F56;
    color: #FFFFFF;
  }
}
.mdlMoney{
  color: #F87D29;
  font-size: 40upx;
  font-family: PingFang SC;
  font-weight: bold;
  margin-bottom: 30rpx;
}
.mdlBoxContent{
  display: flex;
  width: 100%;
  color: #4D4B4B;
  font-weight: 700;
  font-size: 28upx;
  height: 66upx;
  align-items: center;
  text{
    flex: 1;
    text-align: center;
  }
  .time{
    text-align: left;
    flex: 1.5;
  }
  .number{
    text-align: right;
    overflow: hidden;
    white-space: nowrap;
    flex: 1.3;
  }
}
.select{
  font-size: 24upx;
  color: #666666;
}
</style>
